package com.example.hangzhou.welbeing.mytestdemoapp.mvp.personter;

import android.content.Context;
import android.text.TextUtils;

import com.example.hangzhou.welbeing.mytestdemoapp.mvp.model.ISMyLoginModel;
import com.example.hangzhou.welbeing.mytestdemoapp.mvp.model.MyLoginModel;
import com.example.hangzhou.welbeing.mytestdemoapp.mvp.view.ISMyLoginView;

/**
 * 杭州惟君医疗科技有限公司13
 * Created by 20433 on 2018/5/11
 *
 * @desc 东风山河绿，春已不折柳，繁花看不尽，处处惹人留
 * @desc 佛祖镇楼，bug辟容易
 */

public class MyLoginPersenter {
    private ISMyLoginView mISMyLoginView;
    private ISMyLoginModel mISMyLoginModel;

    public MyLoginPersenter(ISMyLoginView mISMyLoginView) {
        this.mISMyLoginView = mISMyLoginView;
        mISMyLoginModel = new MyLoginModel();
    }

    public void JudgeISLogin(Context mcontext) {
        String UserName = mISMyLoginView.getUserName();
        String Password = mISMyLoginView.getPassword();
        if(UserName == null || TextUtils.isEmpty(UserName)){
            mISMyLoginView.showSnackbar("请输入账号");
            return;
        }
        if(UserName == null || TextUtils.isEmpty(UserName)){
            mISMyLoginView.showSnackbar("请输入密码");
            return;
        }
        // TODO 优化
        mISMyLoginModel.saveISLoginDate(mcontext,true);
        mISMyLoginView.toMainActivityPager();
        mISMyLoginView.showSnackbar("登录成功，进入主页");
    }

    public void toRegister(){
        mISMyLoginView.toRegisterActivityPager();
        mISMyLoginView.showSnackbar("进入注册页");
    }
}
